<?php

namespace api\wxapp\model;

use think\Model;
use api\wxapp\model\Shop;
use think\Db;
class Coupon extends Model
{
    protected $table = 'sssc_app_coupon';
    public function getList()
    {
        $date = date('Y-m-d H:i:s',time());
        $where[] = ['stime','elt',$date];
        $where[] = ['etime','egt',$date];
        $where[] = ['status','eq',1];
        return self::where($where)->order('id','desc')->all()
        ->each(function($item,$key){
            if($item['shop_id']){
                $item['lable'] = Shop::where('id',$item['shop_id'])->value('name');
            }else{
                $item['lable'] = '平台通用';
            }
        });
    }
}
